import { runAsWorker } from "synckit";

export type PrettierFormatFn = (source: string, options?: import("prettier").Options) => string;

let prettier: typeof import("prettier");

runAsWorker(async (source, options) => {
  if (!prettier) {
    prettier = await import("prettier");
  }

  return await prettier.format(source, options);
});
